package com.it.whitejotterapi.controller;

import com.it.whitejotterapi.service.impl.SendEmailServiceImpl;
import com.it.whitejotterapi.service.impl.SendMessageImpl;
import com.it.whitejotterapi.tools.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.io.UnsupportedEncodingException;

/**
 * @Author: 羡羡
 * @Date: 2022/05/29/10:49
 */
@RestController
public class SendEmailContoller {
    @Autowired
    SendEmailServiceImpl seim;

    /**
     * 发送短信impl
     */
    @Autowired
    SendMessageImpl sem;

    /**
     * 发送邮件
     * @param to 收邮件的人
     * @param subject 主题
     * @param context 内容
     * @return
     */
    @RequestMapping(path = "/send",method = RequestMethod.POST)
    public JsonResult send(String to,String subject,String context){
        return  seim.sendmessage(to,subject,context);
    }

    /**
     * 发送短信
     * @param iphone 电话
     * @param context 内容
     * @return
     */
    @RequestMapping(path = "/sendmessage",method = RequestMethod.POST)
    public JsonResult sendmes(String iphone,String context) throws UnsupportedEncodingException {
        return sem.sendmes(iphone,context);
    }
}
